import requests


class APIClient():
    """
    普通接口api 封装
    """
    def __init__(self, base_url: str):
        self.base_url = base_url

    def post(self, endpoint: str, headers: dict, json: dict) -> dict:
        """发送 POST 请求"""
        response = requests.post(f"{self.base_url}{endpoint}", headers=headers, json=json, verify=True, timeout=30)
        return response.json()

    # """
    # 云收藏相关接口 api
    # 使用requests 同步调用
    # """
    # @classmethod
    # def parse_resource(cls, headers, data):
    #     """解析资源地址"""
    #     url = BASE_URL + "/offline/parse_resource"
    #     resp = requests.post(url=url, headers=headers, json=data, verify=True, timeout=30)
    #     return resp
    #
    # @classmethod
    # def confirm_download(cls, headers, data):
    #     """确认下载资源"""
    #     url = BASE_URL + "/offline/confirm_download"
    #     resp = requests.post(url=url, headers=headers, json=data, verify=False, timeout=30)
    #     return resp
    #
    # @classmethod
    # def download_list(cls, headers, data):
    #     """离线（云收藏）下载列表"""
    #     url = BASE_URL + "/offline/download_list"
    #     resp = requests.post(url=url, headers=headers, json=data, verify=False, timeout=30)
    #     return resp
